new Vue({
  el: "#app",
  data() {
    return {
      form: {
        Brand_SerialNumber: "",
        Brand_Name: "", //表名
        Picture_URL: "",
      },
      rules: {
        Brand_Name: [
          { required: true, message: "请输入品牌名称", trigger: "blur" },
        ],
      },
      loading: false,
    };
  },
  mounted() {
    // const Brand_SerialNumber = sessionStorage.getItem("Brand_SerialNumber")
    // this.getData(Brand_SerialNumber);
    // this.cpp();
    let Brand_SerialNumber = sessionStorage.getItem("Brand_SerialNumber");
    console.log(Brand_SerialNumber);
    this.getData(Brand_SerialNumber);
  },
  methods: {
    submitForm(formName) {
      console.log(formName);
      const _this = this;
      console.log(_this.form, "*********");
      delete _this.form.Operation_Datetime;
      delete _this.form.Operation_Datetime_Original;
      let lArray = new Array();
      lArray.push(_this.form);
      let lJSONObject_business_brand = new Object();
      lJSONObject_business_brand.business_brand = lArray; //换表
      let lJSONObject_DataSet = new Object();
      lJSONObject_DataSet.Modify = lJSONObject_business_brand;
      console.log(lJSONObject_DataSet);

      //   return;
      $.ajax({
        // headers: requestHeaders(),
        // url: `${BASE_URL2}/generalBusiness/generalPaginationQueryBySQLSerialNumber`,
        url: "https://service.kdddy.cn/donghui/clientOperation/generalSaveForClient",
        type: "POST",
        data: {
          Data: JSON.stringify(lJSONObject_DataSet),
        },
        success: function (Result) {
          console.log(Result);
          if (Result.Status === "success") {
            _this.$message.success("提交成功");
            window.history.go(-1);
          } else {
            _this.$message.error("提交失败，请稍后再试");
          }
        },
        complete: function (XMLHttpRequest) {
          requestPretreatment(XMLHttpRequest); //config/config.js 响应预检
        },
        dataType: "json",
      });
    },
    getData(res) {
      console.log(res);

      const _this = this;
      //子表带原值
      $.ajax({
        // url: "https://service.kdddy.cn/donghuiForRequest/selectByData/EdibleMushroomVariety",
        url: "https://service.kdddy.cn/donghui/generalBusiness/generalQueryByTableNameWithOriginal",
        type: "POST",
        data: {
          Data: "business_brand",
          Condition: "Brand_SerialNumber='" + res + "'",
        },
        success: function (data) {
          console.log(1111111111);
          console.log(data, "data");
          _this.form = data[0];
        },
        complete: function (XMLHttpRequest) {
          //   requestPretreatment(XMLHttpRequest); //config/config.js 响应预检
        },
        dataType: "json",
      });
    },

    // getData(Brand_SerialNumber) {
    //     const that = this;
    //     $.ajax({
    //         headers: requestHeaders(),
    //         type: 'POST',
    //         url: `${BASE_URL2}/generalBusiness/generalQueryByTableNameWithOriginal`,
    //         data: {
    //             Data: "business_brand",
    //             Condition: "Brand_SerialNumber='" + Brand_SerialNumber + "'"
    //         },
    //         success: function (data) {
    //             if (data.length == 1) {
    //                 that.form = data[0];
    //             }
    //         },
    //         complete: function (XMLHttpRequest) {
    //             requestPretreatment(XMLHttpRequest);
    //         },
    //         dataType: "json"
    //     });
    // },
    // submitForm(formName) {
    //     const that = this
    //     this.$refs[formName].validate((valid) => {
    //         if (valid) {
    //             that.loading = true
    //             $.ajax({
    //                 headers: requestHeaders(),
    //                 url: `${BASE_URL2}/generalBusiness/generalSave`,
    //                 type: 'POST',
    //                 data: {
    //                     Data: JSON.stringify({
    //                         Modify: {business_brand: [that.form]},
    //                         Add: {
    //                             base_operation_log:[generateLog('修改品牌数据('+that.form.Brand_Name_Original+'->'+that.form.Brand_Name+')', '平台端操作', 'business_brand', JSON.stringify({ Modify: {business_brand: [that.form]} }))]//日志
    //                         }
    //                     })
    //                 },
    //                 success: function (res) {
    //                     if (res.Status === 'success') {
    //                         that.$message.success("提交成功")
    //                         window.history.go(-1)
    //                     } else {
    //                         that.$message.error("提交失败，请稍后再试")
    //                     }
    //                 },
    //                 error: function () {
    //                     that.$message.error("操作失败，请稍后再试")
    //                 },
    //                 complete: function (XMLHttpRequest) {
    //                     that.loading = false
    //                     requestPretreatment(XMLHttpRequest);
    //                 },
    //                 dataType: "json"
    //             })
    //         } else {
    //             that.$message({
    //                 message: sumberError,
    //                 type: 'warning'
    //             })
    //             return false;
    //         }
    //     });
    // },
    // resetForm(formName) {
    //     this.$refs[formName].resetFields();
    // },
  },
});
